<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    var str = 'abcdefg'
    var arr = []
    for (var i = str.length - 1; i >= 0; i--) {
        arr.push(str.charAt(i))
    }
    // 用join, 会返回一个处理好的字符串
    var str1 = arr.join(' ')
    console.log(str1)
</script>

</html>